import { Button, NavBar } from 'antd-mobile';
import React from 'react'
import { useLocation } from 'react-router-dom'
import { useNavigate } from 'react-router-dom';
import utils from '../../utils/index'
const Deail = () => {
    const navigate = useNavigate()
    const { state } = useLocation()
    console.log(state);

    const zf=async()=>{
     console.log("支付成功");
     const id=new Date().getTime()
     const resp=await utils.get('/pay',{params:{title:"火车票",id:id,price:1000}})
     window.open(resp.data.data)
    }
    return (
        <div>
            <NavBar onBack={() => navigate(-1)}>详情</NavBar>
            <dl
                style={{
                    display: 'flex',
                    justifyContent: 'space-around',
                    padding: '10px',
                }}
            >
                <dt>{state.start}-{state.end}</dt>
                <dd>
                    <div>是否高铁:{state.isSeat ? '非高铁' : '高铁'}</div>
                    <div>是否高铁:{state.isSpeed ? '无座' : '有票'}</div>
                </dd>
                <dd>
                    <div>商务座:{state.tick.vip}</div>
                    <div>一等座:{state.tick.firstTick}</div>
                    <div>二等座:{state.tick.secondTick}</div>
                </dd>
            </dl>
            <Button block color='primary' onClick={() => zf()}>支付</Button>
        </div>
    )
}

export default Deail
